package main

import (
	"fmt"
)

func div2(a, b int) (res int, err error) {
	if b == 0 {
		panic("除数不能为0") //中断程序
	} else {
		res = a / b
	}
	return
}

func main() {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
		}
	}()

	ch := make(chan int)

	go func() {
		result, err := div2(2, 0)
		if err != nil {
			fmt.Println("###err:", err)
		}
		ch <- result
	}()
	fmt.Println("result:", <-ch)
}
